# coding=utf-8
from appium import webdriver
import time

# desired_caps = {
#             'platformName':'Android',
#             'platformVersion':'6.0.1',
#             'deviceName':'d2b0ab88'
#         }
# desired_caps["unicodeKeyboard"]="True"
# desired_caps["resetKeyboard"]="True"
# desired_caps['appPackage'] = 'com.miui.calculator'
# desired_caps['appActivity'] = '.cal.CalculatorActivity'
# driver = webdriver.Remote('http://localhost:4723/wd/hub',desired_caps)
#
# driver.find_element_by_id("com.miui.calculator:id/btn_1").click()
#
# driver.find_element_by_id("com.miui.calculator:id/btn_plus").click()
#
# driver.find_element_by_id("com.miui.calculator:id/btn_9").click()
#
# driver.find_element_by_id("com.miui.calculator:id/btn_mul").click()
# driver.find_element_by_id("com.miui.calculator:id/btn_8").click()


# .view.setup.SetUpActivity
# .view.home.HomeActivity
# .view.introduce.IntroduceActivity
# .view.login.LoginActivity

desired_caps = {'platformName': 'Android',
                'platformVersion': '5.1',
                'deviceName': '85GACMEA3GVE',
                "unicodeKeyboard": "True",
                "resetKeyboard": "True",
                'appPackage': 'com.milelc.online',
                'appActivity': '.view.setup.SetUpActivity'}
desired_caps['unicodeKeyboard']='True'
desired_caps['resetKeyboard']='True'
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

time.sleep(5)
driver.swipe(1060, 960, 20, 960, 1000)
driver.swipe(1060, 960, 20, 960, 1000)
driver.swipe(1060, 960, 20, 960, 1000)

driver.find_element_by_id('com.milelc.online:id/introduce_button').click()

driver.find_element_by_id('com.milelc.online:id/radio_mine').click()
username = driver.find_element_by_id('com.milelc.online:id/edit_phone')
password = driver.find_element_by_id('com.milelc.online:id/edit_pwd')

print(username.text)
print(password.text)

#username.click()
username.send_keys('18248781234')
#password.click()
password.send_keys('abcd1234')

driver.find_element_by_id('com.milelc.online:id/button_login').click()

driver.quit()
